title=""
url="/account/orders.html"

layout="default"

is_hidden = 0
description = "用户订单列表"

[session]
security = "user"
redirect = "account/login"
==
<?
    function onStart(){
    $this['status'] = get('status');
    $a = App::make('Jason\Ccshop\Components\Catalog')->orders();
//dd($a[0]['products'][0]['options']);
        $this->addJs('assets/js/com-checkout.js');
    }
?>
==
{% put page_title %}DASHBOARD{% default %}{% endput %}
{% set orders = catalog.orders %}
{% set Addresses = catalog.getAddresses %}
<!-- contents -->
<div class="content">
        <div class="title-return">
            <h2>注文履歴</h2>
            <a href="javascript:;" onclick="history.go(-1);return false;"><img src="{{ 'assets/img/btn_back.gif'|theme}}" alt="戻る"></a>
        </div>
        <div class="order-tab">
            <ul class="order-tab-ul">
                <li {% if status =='' %} class="active" {% endif %} data-status="{{ 'account/orders'|page }}">注文履歴({{ oall }})</li>
                <li {% if status =='op' %} class="active" {% endif %} data-status="{{ 'account/orders'|page }}?status=op">未入金({{op}})</li>
                <li {% if status =='oa' %} class="active" {% endif %} data-status="{{ 'account/orders'|page }}?status=oa">支払い済み({{oa}})</li>
                <li {% if status =='ob' %} class="active" {% endif %} data-status="{{ 'account/orders'|page }}?status=ob">配送済み({{ob}})</li>
                <li {% if status =='cr' %} class="active" {% endif %} data-status="{{ 'account/orders'|page }}?status=cr">キャンセル({{ cr }})</li>
            </ul>
            <div class="order-cont">
                <div class="order-content"  {% if status =='' %}style="display:block;"{% endif %} >
                    {% if count(orders) > 0 and oall > 0 %}
                    {% for key, order in orders %}
                    <div class="order-des">                     
                        <h3>
                            <a href="/orderdetail-{{ order.sn }}.html">注文NO：{{ order.sn }}<br>
                                <span>ご注文日付と時間：{{ formatDate("m-d-Y H:i:s", order.created_at) }}</span>
                            </a>
                        </h3>                       
                        {% for m, orderproduct in order.products %}
                        {% set condition = { 'id': orderproduct.product_id } %}
                        {% set product = catalog.product(condition) %}
                        <div class="description">
                            <p class="prdImg">
                                <a href="{{product.url}}"><img src="{{ product.getMainThumb(80,80) }}"></a>
                            </p>
                            <strong class="prdName"><a href="{{product.url}}">{{ orderproduct.name }}</a></strong>
                            <ul class="info info-other">
                                <li>
                                    {%for m,option in orderproduct.options %}
                                    <span>{{m}}:{{option[0]}}</span>
                                    {% endfor %}    
                                </li>
                                <li>
                                    <span class="price"><strong>{{ orderproduct.price|formatPriceNotRate }}</strong></span>
                                    <span><strong>× {{ orderproduct.qty }}</strong>個</span>
                                </li>
                            </ul>
                        </div>
                       <!-- <p class="option">
                            {%for m,option in orderproduct.options %}
                            [{{m}}:{{option[0]}}]
                            {% endfor %}
                        </p>-->
                       <!-- <p class="option">[オプション: ピンク]</p>-->
                        {% endfor %}
                        {% partial 'account/order-status-operation' order=order %}
                        <a href="/orderdetail-{{ order.sn }}.html" class="btnDetail"><td>{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}</td><span class="fa fa-angle-right"></span></a>
                    </div>
                    {% endfor %}
                    {% else %}
                        <div class="empty">
                            履歴がありません
                        </div>
                    {% endif %}
                </div>
                <div class="order-content" {% if status =='op' %}style="display:block;"{% endif %}>
                    {% if count(orders) > 0 and op > 0 %}
                    {% for key, order in orders %}
                    {% if order.order_status.code == 'placed'%}
                    <div class="order-des">
                        <h3>
                            <a href="/orderdetail-{{ order.sn }}.html?status=op">注文NO：{{ order.sn }}<br>
                                <span>ご注文日付と時間：{{ formatDate("m/d/Y H:i:s", order.created_at) }}</span>
                            </a>
                        </h3>
                        {% for m, orderproduct in order.products %}
                        {% set condition = { 'id': orderproduct.product_id } %}
                        {% set product = catalog.product(condition) %}
                        <div class="description">
                            <p class="prdImg">
                                <a href="{{product.url}}"><img src="{{ product.getMainThumb(80,80) }}"></a>
                            </p>
                            <strong class="prdName"><a href="{{product.url}}">{{ orderproduct.name }}</a></strong>
                            <ul class="info info-other">
                                <li>
                                    {%for m,option in orderproduct.options %}
                                    <span>{{m}}:{{option[0]}}</span>
                                    {% endfor %}    
                                </li>
                                <li>
                                    <span class="price"><strong>{{ orderproduct.price|formatPriceNotRate }}</strong></span>
                                    <span><strong>× {{ orderproduct.qty }}</strong>個</span>
                                </li>
                            </ul>
                        </div>

                        <!--<p class="option">[オプション: ピンク]</p>-->
                        {% endfor %}
                        {% partial 'account/order-status-operation' order=order %}
                        <!--<p class="status">
                            {{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}
                        </p>-->
                        <a href="/orderdetail-{{ order.sn }}.html?status=op" class="btnDetail">{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}<span class="fa fa-angle-right"></span></a>
                    </div>
                    {% endif %}
                    {% endfor %}
                    {% else %}
                    <div class="empty">
                        履歴がありません
                    </div>
                    {% endif %}
                </div>
                <div class="order-content" {% if status =='oa' %}style="display:block;"{% endif %}>
                    {% if count(orders) > 0 and oa > 0 %}
                    {% for key, order in orders %}
                    {% if order.order_status.code == 'paid'%}
                    <div class="order-des">
                        <h3>
                            <a href="/orderdetail-{{ order.sn }}.html?status=oa">注文NO：{{ order.sn }}<br>
                                <span>ご注文日付と時間：{{ formatDate("m/d/Y H:i:s", order.created_at) }}</span>
                            </a>
                        </h3>
                        {% for m, orderproduct in order.products %}
                        {% set condition = { 'id': orderproduct.product_id } %}
                        {% set product = catalog.product(condition) %}
                        <div class="description">
                            <p class="prdImg">
                                <a href="{{product.url}}"><img src="{{ product.getMainThumb(80,80) }}"></a>
                            </p>
                            <strong class="prdName"><a href="{{product.url}}">{{ orderproduct.name }}</a></strong>
                            <ul class="info info-other">
                                <li>
                                    {%for m,option in orderproduct.options %}
                                    <span>{{m}}:{{option[0]}}</span>
                                    {% endfor %}    
                                </li>
                                <li>
                                    <span class="price"><strong>{{ orderproduct.price|formatPriceNotRate }}</strong></span>
                                    <span><strong>× {{ orderproduct.qty }}</strong>個</span>
                                </li>
                            </ul>
                        </div>
                        <!--<p class="option">[オプション: ピンク]</p>-->
                        {% endfor %}
                        <!--<p class="status">
                            {{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}
                        </p>-->
                        {% partial 'account/order-status-operation' order=order %}
                        <a href="/orderdetail-{{ order.sn }}.html?status=oa" class="btnDetail">{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}<span class="fa fa-angle-right"></span></a>
                    </div>
                    {% endif %}
                    {% endfor %}
                    {% else %}
                    <div class="empty">
                        履歴がありません
                    </div>
                    {% endif %}
                </div>
                <div class="order-content" {% if status =='ob' %}style="display:block;"{% endif %}>
                    {% if count(orders) > 0 and ob > 0 %}
                    {% for key, order in orders %}
                    {% if order.order_status.code == 'delivered' %}
                    <div class="order-des">
                        <h3>
                            <a href="/orderdetail-{{ order.sn }}.html?status=ob">注文NO：{{ order.sn }}<br>
                                <span>ご注文日付と時間：{{ formatDate("m/d/Y H:i:s", order.created_at) }}</span>
                            </a>
                        </h3>
                        {% for m, orderproduct in order.products %}
                        {% set condition = { 'id': orderproduct.product_id } %}
                        {% set product = catalog.product(condition) %}
                        <div class="description">
                            <p class="prdImg">
                                <a href="{{product.url}}"><img src="{{ product.getMainThumb(80,80) }}"></a>
                            </p>
                            <strong class="prdName"><a href="{{product.url}}">{{ orderproduct.name }}</a></strong>
                            <ul class="info info-other">
                                <li>
                                    {%for m,option in orderproduct.options %}
                                    <span>{{m}}:{{option[0]}}</span>
                                    {% endfor %}    
                                </li>
                                <li>
                                    <span class="price"><strong>{{ orderproduct.price|formatPriceNotRate }}</strong></span>
                                    <span><strong>× {{ orderproduct.qty }}</strong>個</span>
                                </li>
                            </ul>
                        </div>
                       
                        <!--<p class="option">[オプション: ピンク]</p>-->
                        {% endfor %}
                        {% partial 'account/order-status-operation' order=order %}
                       <!-- <p class="status">
                            {{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}
                        </p>-->
                        <a href="/orderdetail-{{ order.sn }}.html?status=ob" class="btnDetail">{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}<span class="fa fa-angle-right"></span></a>
                    </div>
                    {% endif %}
                    {% endfor %}
                    {% else %}
                    <div class="empty">
                        履歴がありません
                    </div>
                    {% endif %}
                </div>
                <div class="order-content" {% if status =='cr' %}style="display:block;"{% endif %}>
                    {% if count(orders) > 0 and cr > 0 %}
                    {% for key, order in orders %}
                    {% if order.order_status.code == 'canceled' or  order.order_status.code == 'refunded' %}
                    <div class="order-des">
                        <h3>
                            <a href="/orderdetail-{{ order.sn }}.html?status=cr">注文NO：{{ order.sn }}<br>
                                <span>ご注文日付と時間：{{ formatDate("m/d/Y H:i:s", order.created_at) }}</span>
                            </a>
                        </h3>
                        {% for m, orderproduct in order.products %}
                        {% set condition = { 'id': orderproduct.product_id } %}
                        {% set product = catalog.product(condition) %}
                        <div class="description">
                            <p class="prdImg">
                                <a href="{{product.url}}"><img src="{{ product.getMainThumb(80,80) }}"></a>
                            </p>
                            <strong class="prdName"><a href="{{product.url}}">{{ orderproduct.name }}</a></strong>
                            <ul class="info info-other">
                                <li>
                                    {%for m,option in orderproduct.options %}
                                    <span>{{m}}:{{option[0]}}</span>
                                    {% endfor %}    
                                </li>
                                <li>
                                    <span class="price"><strong>{{ orderproduct.price|formatPriceNotRate }}</strong></span>
                                    <span><strong>× {{ orderproduct.qty }}</strong>個</span>
                                </li>
                            </ul>
                        </div>
                        
                        <!--<p class="option">[オプション: ピンク]</p>-->
                        {% endfor %}
                        {% partial 'account/order-status-operation' order=order %}
                       <!-- <p class="status">
                            {{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}
                        </p>-->
                        <a href="/orderdetail-{{ order.sn }}.html?status=cr" class="btnDetail">{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}<span class="fa fa-angle-right"></span></a>
                    </div>
                    {% endif %}
                    {% endfor %}
                    {% else %}
                    <div class="empty">
                        履歴がありません
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
</div>
<!-- end contents -->
{% partial 'account/order-cancel-pop' %}
{% put scripts %}
<script type="text/javascript">
    $(function($) {
        $(".order-tab-ul li").bind("click", function(){
            var status = $(this).attr('data-status');
            window.location.href = status;
        });
    });
</script>
{% endput %}

